package com.cssw.fyzb.wap.service;

import com.cssw.fyzb.base.web.domain.AjaxData;
import com.cssw.fyzb.base.web.domain.AjaxPage;
import com.cssw.fyzb.wap.model.vo.CreateLivePkVo;
import com.cssw.fyzb.wap.model.vo.LiveFriendVo;
import com.ydn.appserver.MinaAppClient;
import com.ydn.appserver.Request;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author wondream
 */
@Service
public class LivePkService extends BaseService {

    private static final Logger logger = LoggerFactory.getLogger(UserService.class);

    @Autowired
    private MinaAppClient busiClient;

    /**
     * 发起直播PK
     *
     * @return
     */
    public AjaxData<CreateLivePkVo> addLivePk(Long userId, Long fromLiveId, Long toLiveId) {
        Request request = new Request("CreateLivePk");
        request.setParameter("userId", userId);
        request.setParameter("fromLiveId", fromLiveId);
        request.setParameter("toLiveId", toLiveId);
        return convertData(busiClient.send(request), CreateLivePkVo.class);
    }

    /**
     * 关闭直播PK
     *
     * @return
     */
    public AjaxData closeLivePk(Long userId, Long id) {
        Request request = new Request("CloseLivePk");
        request.setParameter("userId", userId);
        request.setParameter("pkId", id);
        return convertData(busiClient.send(request));
    }

    /**
     * 查询直播好友列表
     *
     * @param userId
     * @param pageNumber
     * @param pageSize
     * @return
     */
    public AjaxPage<LiveFriendVo> listLiveFriend(Long userId, Integer pageNumber, Integer pageSize) {
        Request request = new Request("ListLiveFriend");
        request.setParameter("userId", userId);
        request.setParameter("pageNumber", pageNumber);
        request.setParameter("pageSize", pageSize);
        return convertPage(busiClient.send(request), LiveFriendVo.class);
    }

    /**
     * 同城匹配
     *
     * @param userId
     * @return
     */
    public AjaxData sameCityMatch(Long userId) {
        Request request = new Request("SameCityMatchPk");
        request.setParameter("userId", userId);
        return convertData(busiClient.send(request));
    }

    /**
     * 全国匹配
     *
     * @param userId
     * @return
     */
    public AjaxData nationwideMatch(Long userId) {
        Request request = new Request("NationwideMatchPk");
        request.setParameter("userId", userId);
        return convertData(busiClient.send(request));
    }
}
